package com.xuchaotong.utils;

import com.google.gson.Gson;
import com.xuchaotong.utils.bean.GetOrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.net.URL;

@Slf4j
public class JsonConvertUtils {


    @Test
    public void testJsonFile(){
        ClassLoader classLoader = getClass().getClassLoader();
        URL url = classLoader.getResource("data/a.json");

        File file = new File(url.getFile());

        try {
            String json = FileUtils.readFileToString(file,"UTF-8");
            GetOrderInfo getOrderInfo = new Gson().fromJson(json, GetOrderInfo.class);

//            log.info("加密手机号：{}",getOrderInfo.getConsigneeInfo().getDesenMobile());
//            log.info("加密电话号：{}",getOrderInfo.getConsigneeInfo().getDesenTelephone());
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
